package EmailService;

import java.util.Properties;

/**
 * 接收邮件信息类
 * 使用IMAP协议(POP3协议不支持判断邮件是否已读)
 * @author Senze.Zheng
 */
public class ReceiveInfo {

    // 接收邮件的服务器IP
    private String mailServerHost;
    // 接收邮件的服务器端口
    private String mailServerPort = "143";
    // 登录邮件接收服务器的用户名和密码
    private String userName;
    private String userPassword;
    // 是否需要身份验证
    private boolean validate = false;
    // 协议
    private String protocol = "imap";

    /**
     * 获得接收邮件所需的Properties对象
     * @return 配置邮件信息的环境属性
     */
    public Properties getProperties(){
        Properties props = new Properties();
        props.put("mail.store.protocol",this.protocol);
        props.put("mail.imap.host",this.mailServerHost);
        props.put("mail.imap.port",this.mailServerPort);
        props.put("mail,imap.auth",validate ? "true" : "false");
        props.put("mail.imap.auth.login.disable","true");
        return props;
    }

    public String getMailServerHost() {
        return mailServerHost;
    }

    public void setMailServerHost(String mailServerHost) {
        this.mailServerHost = mailServerHost;
    }

    public String getMailServerPort() {
        return mailServerPort;
    }

    public void setMailServerPort(String mailServerPort) {
        this.mailServerPort = mailServerPort;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    public boolean isValidate() {
        return validate;
    }

    public void setValidate(boolean validate) {
        this.validate = validate;
    }

    public String getProtocol() {
        return protocol;
    }

    public void setProtocol(String protocol) {
        this.protocol = protocol;
    }
}
